from api.Add_car import Add_Car
from api.Litemail_login import Litemail


class Test_addcar:
    Token = None

    # 前置操作
    def setup_method(self):
        # 实例化加入购物车
        self.add = Add_Car()
        self.login = Litemail()

        json01 = {"username": "user123", "password": "user123"}
        rep = self.login.get_login(json01)
        Test_addcar.Token = rep.json().get("data")["token"]

    # 后置操作
    def teardown_method(self):
        pass

    # 加入购物车
    def test_addcar_success(self):
        data = {"goodsId": "1181000", "number": 1, "productId": 2}
        rsp = self.add.add_car(Test_addcar.Token, data)
        assert "成功" in rsp.text
